import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { QuotationVO, QuotationForm, QuotationQuery } from '@/api/goods/quotation/types';

/**
 * 查询报价方案列表
 * @param query
 * @returns {*}
 */

export const listQuotation = (query?: QuotationQuery): AxiosPromise<QuotationVO[]> => {
  return request({
    url: '/order/quotation/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询报价方案列表
 * @param query
 * @returns {*}
 */

export const listQuotationAll = (query?: QuotationQuery): AxiosPromise<QuotationVO[]> => {
  return request({
    url: '/order/quotation/listNotPage',
    method: 'get',
    params: query
  });
};

/**
 * 查询报价方案详细
 * @param id
 */
export const getQuotation = (id: string | string[]): AxiosPromise<QuotationVO> => {
  return request({
    url: '/order/quotation/' + id,
    method: 'get'
  });
};

/**
 * 查询报价方案详细
 */
export const getQuotationAllList = (): AxiosPromise<QuotationVO> => {
  return request({
    url: '/order/quotation/allList',
    method: 'get'
  });
};

/**
 * 查询报价方案详细
 */
export const getQuotationCode = (): AxiosPromise<QuotationVO> => {
  return request({
    url: '/order/quotation/getQuotationCode',
    method: 'get'
  });
};

/**
 * 新增报价方案
 * @param data
 */
export const addQuotation = (data: QuotationForm) => {
  return request({
    url: '/order/quotation',
    method: 'post',
    data: data
  });
};

/**
 * 修改报价方案
 * @param data
 */
export const updateQuotation = (data: QuotationForm) => {
  return request({
    url: '/order/quotation',
    method: 'put',
    data: data
  });
};

/**
 * 删除报价方案
 * @param id
 */
export const delQuotation = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/quotation/' + id,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param quotationId 客户端id
 * @param status 状态
 */
export function changeStatus(quotationId: string, status: string) {
  const data = {
    quotationId,
    status
  };
  return request({
    url: '/order/quotation/changeStatus',
    method: 'put',
    data: data
  });
}

export default {
  list:listQuotation,
  get:getQuotation,
  add:addQuotation,
  update:updateQuotation,
  del:delQuotation,
  getQuotationAllList:getQuotationAllList
}